<template>
  <div style="margin-top: 10px">
    <el-card class="box-card">
      <template #header>
        <div class="card-header">
          <span class="search-card-title"> Personal Information</span>
          <el-col
            :span="6"
            :offset="16"
            style="text-align: end; padding-right: 10px"
          >
            <el-button
              size="medium"
              type="primary"
              icon="el-icon-s-fold"
              @click="returnTo()"
              >Return</el-button
            >
          </el-col>
        </div>
      </template>
      <el-row type="flex" justify="center">
        <el-col :span="23">
          <span>
            <el-descriptions title="Role Information" border :column="1">
              <el-descriptions-item
                :labelStyle="{ background: '#e1f3d8' }"
                :contentStyle="{ background: '#FDE2E2' }"
              >
                <template slot="label">
                  <i class="el-icon-user-solid"></i>
                  Nickname
                </template>
                <div v-if="isUpdate == false">{{ form.nickname }}</div>
                <el-input
                  v-model="form.nickname"
                  v-if="isUpdate == true"
                ></el-input>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-user"></i>
                  Gender
                </template>
                <div v-if="isUpdate == false">{{ form.gender }}</div>
                <el-input
                  v-model="form.gender"
                  v-if="isUpdate == true"
                ></el-input>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-star-on"></i>
                  Age
                </template>
                <div v-if="isUpdate == false">{{ form.age }}</div>
                <el-input v-model="form.age" v-if="isUpdate == true"></el-input>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-mobile-phone"></i>
                  Phone
                </template>
                <div v-if="isUpdate == false">{{ form.phone }}</div>
                <el-input
                  v-model="form.phone"
                  v-if="isUpdate == true"
                ></el-input>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-chat-round"></i>
                  WeChat
                </template>
                <div v-if="isUpdate == false">{{ form.wechat }}</div>
                <el-input
                  v-model="form.wechat"
                  v-if="isUpdate == true"
                ></el-input>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">QQ</template>
                <div v-if="isUpdate == false">{{ form.QQ }}</div>
                <el-input v-model="form.QQ" v-if="isUpdate == true"></el-input>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-map-location"></i>
                  Address
                </template>
                <div v-if="isUpdate == false">{{ form.address }}</div>
                <el-input
                  v-model="form.address"
                  v-if="isUpdate == true"
                ></el-input>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-message"></i>
                  Email
                </template>
                <div v-if="isUpdate == false">{{ form.email }}</div>
                <el-input
                  v-model="form.email"
                  v-if="isUpdate == true"
                ></el-input>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-date"></i>
                  Registration DateTime
                </template>
                2020-03-04 05:12:23
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-s-custom"></i>
                  Role
                </template>
                <el-tag size="medium">User</el-tag>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-star-off"></i>
                  Status
                </template>
                <el-tag size="medium" type="success">activation</el-tag>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-s-grid"></i>
                  Number of Questionnaires
                </template>
                <el-tag size="medium" type="warning">5</el-tag>
              </el-descriptions-item>
            </el-descriptions>
          </span></el-col
        >
      </el-row>
      <br />
      <el-row>
        <el-col
          :span="6"
          :offset="18"
          style="text-align: end; padding-top: 10px; padding-right: 10px"
        >
          <el-button
            v-if="isUpdate == false"
            type="primary"
            size="mini"
            @click="isUpdate = true"
            >Update</el-button
          >
          <el-button
            v-if="isUpdate == true"
            type="success"
            size="mini"
            @click="confirmModify()"
            >confirm</el-button
          >
          <el-button type="info" size="mini" @click="isUpdate = false"
            >Cancel</el-button
          >
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isUpdate: false,
      form: {
        nickname: "kooriookami",
        gender: "女",
        age: "32",
        phone: "13526548956",
        wechat: "无边落木萧萧下",
        QQ: "152625424",
        address: "陕西省铜川市xx县xx村xx号",
        email: "154135fsdfsd1351@163.com",
      },
    };
  },
  methods: {
    returnTo() {
      this.$router.push("/home");
    },
    confirmModify() {
      this.$message({
        type: "success",
        message: "修改成功!",
      });
      this.isUpdate = false;
    },
  },
};
</script>

<style scoped lang="scss">
.box-card {
  width: 90%;
  background: rgba(148, 185, 228, 0.062);
  border-radius: 8px;
  margin: auto;
}
.box-card1 {
  background: rgba(148, 185, 228, 0.062);
  border-radius: 8px;
}
.card-header {
  color: #080808;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.search-card-title {
  width: 100%;
  font-size: 16px;
  font-weight: 600;
}
.el-card /deep/.el-card__header {
  background-color: #64bbe742;
  padding: 6px;
}
.my-label {
  background: #e1f3d8;
}
</style>